Learn R Programming

XBRL (version 0.99.17)

Low-level functions: Set of low-level functions to parse an XBRL file and extract information from it.

Description

xbrlParse performs the parsing of the document. It returns a pointer to external memory used by the low-level functions. xbrlFree releases the external memory used. xbrlGetSchemaName is used on an instance document to extract the name of the associated schema. xbrlGetLinkbaseNames and xbrlGetImportNames are used on a taxonomy document to extract the names of linked documents during the process of discovery. xbrlProcessXXX functions are used to extract information from taxonomy and instance files in the form of data frames.

Usage

## Use on any XBRL file xbrlParse(file) xbrlFree(doc)
## Use on an instance file xbrlGetSchemaName(doc)
## Use on a taxonomy file xbrlGetLinkbaseNames(doc) xbrlGetImportNames(doc)
xbrlProcessElements(doc) xbrlProcessLabels(doc) xbrlProcessArcs(doc, arcType)
## Use on a schema file xbrlProcessRoles(doc)
## Use on an instance file xbrlProcessContexts(doc) xbrlProcessFacts(doc) xbrlProcessUnits(doc) xbrlProcessFootnotes(doc)

Arguments

file
the name of the XBRL document. It can be a URL or local file name
doc
pointer to external memory, returned by xbrlParse
arcType
Either "presentation", "calculation", or "definition"

Value

xbrlParse returns an external pointer.xbrlFree returns NULL.xbrlGetSchemaName, xbrlGetLinkbaseNames and xbrlGetImportNames return a character vectorxbrlProcessXXX returns a data.frame

See Also

xbrlDoAll

Examples

Run this code
## Not run: 
# ## Setting stringsAsFactors = FALSE is highly recommended
# ## to avoid data frames to create factors from character vectors.
# options(stringsAsFactors = FALSE)
# 
# ## XBRL instance file to be analyzed.
# ## NOTE: in this case, inst needs to be a local file, or accessible
# ##       as http (not https).
# inst <- "ko-20130927.xml"
# ## Parse the instance (doc is an pointer to
# ## external memory that needs to be freed after use):
# doc <- xbrlParse(inst)
# ## Get a data frame with facts:
# fct <- xbrlProcessFacts(doc)
# ## Get a data frame with contexts:
# cts <- xbrlProcessContexts(doc)
# ## Get a data frame with units:
# unt <- xbrlProcessUnits(doc)
# sch <- xbrlGetSchemaName(doc)
# ## Free the external memory used:
# xbrlFree(doc)
# 
# dname <- dirname(inst)
# ## Parse the schema file:
# docS <- xbrlParse(paste0(dname,"/",sch))
# ## Get roles:
# rls <- xbrlProcessRoles(docS)
# head(rls)
# ## Free the external memory used:
# xbrlFree(docS)
# ## End(Not run)

Run the code above in your browser using DataLab